package ink.lovejinhu.leetcode;

/**
 * @author jinhu
 * created 2021-08-05 16:58
 */
public class Solution_0747 {
    public int dominantIndex(int[] nums) {
        int max = Integer.MIN_VALUE;
        int shouwLocation = -1;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] > max) {
                max = nums[i];
                shouwLocation = i;
            }
        }
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == 0 || nums[i] == max) {
                continue;
            } else {
                if (nums[i] * 2 <= max) {
                    continue;
                } else {
                    return -1;
                }
            }
        }
        return shouwLocation;
    }
}
